<?php
require 'core/header.php';
if ($_POST) {
    if (isset($_POST['post'])) {
        switch ($_POST['post']) {
            case "signin"://注册
                sql_signin($_POST['username'], $_POST['password'], $_POST['rank']);
            case "login"://登录
                sql_login($_POST['username'], $_POST['password'], $_POST['verify']);
            case "logout"://登出
                {
                    session_unset();
                    session_destroy();
                    exit('success');
                }
            case "addArea"://增加论坛区
                sql_addArea(htmlspecialchars($_POST['areaname']), $_POST['areaorder']);
            case "addForum"://增加板块
                sql_addforums(htmlspecialchars($_POST['forumname']), $_POST['forumareaid'], $_POST['forumdesc']);
            case "editAreaName"://修改论坛区名称
                sql_deit_areatitle(htmlspecialchars($_POST['areaname']), $_POST['areaid']);
            case "editForum"://修改论坛名
                sql_edit_forum(htmlspecialchars($_POST['forumname']), $_POST['forumid'], $_POST['auth_post'], $_POST['auth_edit'], $_POST['forum_desc']);
            case "editauth_post":
                sql_edit_auth_post(htmlspecialchars($_POST['auth_post']), $_POST['forumid']);
            case "edit_replydel":
                sql_edit_replydel($_POST['postid']);
            case "addTopic"://发表帖子
                $topic_title = htmlspecialchars(trim($_POST['title']));
                sql_editCoins($_SESSION['uid'], 1);
                sql_addExp($_SESSION['uid'], 5);
                sql_add_topic($_POST['forumid'], $topic_title, $_SESSION['uid'], $_POST['vote'], $_POST['content']);
            case "editTopic" :
                sql_edit_topic($_POST['title'], $_POST['content'], $_POST['vote'], $_POST['tid'], $_POST['selectType'], $_POST['settop'], $_POST['fid'], $_POST['selectForumVal']);
            case "replyTopic"://回复帖子
                sql_editCoins($_SESSION['uid'], 1);
                sql_addExp($_SESSION['uid'], 1);
                sql_addNotify($_POST['topicid'], $_SESSION['uid']);
                sql_reply_topic($_POST['topicid'], 1, $_POST['content'], $_SESSION['uid']);
            case "lzlPost"://回复楼中楼
                sql_add_lzl($_POST['tid'], $_POST['lzlcontent'], $_POST['pid'], $_POST['uid']);
            case "change_username":
                sql_change_username($_POST['uid'], $_POST['username']);
            case "change_password":
                sql_change_password($_POST['uid'], $_POST['get_password'], $_POST['set_password']);
            case "editusers":
                sql_edit_users($_POST['uid'], $_POST['sex'], $_POST['date'], $_POST['website'], $_POST['ownspeak'], $_POST['isignatur'], $_POST['email']);
            case "edit_replyhide":
                sql_edit_replyhide($_POST['postid']);
            case "delUser":
                sql_delUser($_POST['uid']);
            case "editRank":
                if ($_POST['select'] == 1) {
                    $rank = 0;
                } elseif ($_POST['select'] == 2) {
                    if (isset($_POST['selectForum'])) {
	                    $rank = $_POST['selectForum'];
                    }
                } elseif ($_POST['select'] == 3) {
                    $rank = 10;
                }
                sql_editRank($_POST['uid'], $rank);
            case "buyMedal":
                sql_buy_medal($_POST['uid'], $_POST['medalId']);
            case "addMedal":
                sql_add_medal($_POST['medalName'], $_POST['medalUrl'], $_POST['medalSale']);
            case "delUserMedal":
                sql_delUserMedal($_POST['uid'], $_POST['mid']);
            case "addCoins":
                sql_addCoins($_POST['uid'], $_POST['addCoins']);
            case "editCoinName":
                sql_editCoinName(htmlspecialchars($_POST['scoreName']));
            case "edittopicstatus":
                sql_edit_status($_POST['topicid'], $_POST['statusType']);
            case "add_key":
                sql_add_key($_POST['key'], $_POST['change']);
            case "del_key":
                sql_del_key($_POST['id']);
            case "changeBg":
                sql_change_bg($_POST['uid'], $_POST['color']);
            case "addLike":
                sql_addLike($_POST['postid']);
                break;
            case "selectFrom":
                sql_selectFrom($_POST['areaid']);
                break;
            case "loginout":
                sql_loginout($_POST['uid'], $_POST['time']);
                break;
            default:
                header("Localtion:forum.php");
        }
    } else {
        header("Localtion:forum.php");
    }
} else {
    header("Localtion:forum.php");
}


